#ifndef PROTOCOL_H
#define PROTOCOL_H

#include "bsp_usart.h"

#define FRAME_HEADER 0x7B
#define FRAME_TAIL 0x7D
#define FRAME_HEADER_LEN 3
#define FRAME_TAIL_LEN 1

typedef struct
{
    uint8_t header[FRAME_HEADER_LEN];
    uint8_t tail[FRAME_TAIL_LEN];
    USARTInstance *instance;
} Protocol_Parameter_s;

typedef struct 
{
    uint8_t data[256];
    Protocol_Parameter_s *protocol_params;
}Protocol_Config_s;


typedef enum
{
    PROTOCOL_OK = 0,
    PROTOCOL_ERROR = 1,
}protocol_state_e;

Protocol_Config_s *ProtocolInit(UART_HandleTypeDef *_instance);
void Protocol_Send(uint8_t *data, uint8_t len);
void Protocol_Recv(void);

uint8_t Check_Sum(unsigned char Count_Number,unsigned char mode, uint8_t *data);
#endif // PROTOCOL_H